{% block content %}
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                    aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">新建栏目</h4>
    </div>
    <div class="modal-body">
        <p id="tip"></p>
        <!-- form start -->
        <div class="box-body">
            <form class="form-horizontal" method="post" id="form-form">
                <div class="form-group">
                    <label for="lb-name" class="col-sm-3 control-label">
                        <span style="color:red">*</span>栏目名
                    </label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="name">
                    </div>
                </div>
                <div class="form-group">
                    <label for="lb-active" class="col-sm-3 control-label">
                        <span style="color:red">*</span>启用
                    </label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="active">
                    </div>
                </div>
                <div class="form-group">
                    <label for="lb-module" class="col-sm-3 control-label">
                        <span style="color:red">*</span>模块
                    </label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="module">
                    </div>
                </div>
                <div class="form-group">
                    <label for="lb-parent" class="col-sm-3 control-label">
                        <span style="color:red">*</span>父级
                    </label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="parent">
                    </div>
                </div>
                <div class="form-group">
                    <label for="lb-sequence" class="col-sm-3 control-label">
                        <span style="color:red">*</span>排序
                    </label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" name="sequence">
                    </div>
                </div>
            </form>
        </div>
        <!-- /.box-body -->
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-info" onclick="return formSubmit()">提交</button>
    </div>
{% endblock %}
{% block extend_scripts %}
    <script>
        function formSubmit() {
            $.ajax(
                {
                    url: "./column/add",
                    data: $('#form-form').serialize(),
                    type: "POST",
                    beforeSend: function () {
                        $("#tip").html('<div class="alert alert-info alert-dismissible"><i class="icon fa fa-info"></i>请稍等...</div>');
                        return true;
                    },
                    success: function (data) {
                        data = JSON.parse(data);
                        if (data['state']) {
                            $("#tip").html(data['data']);
                            $("#table").DataTable().ajax.reload(null, false);   //重新加载DataTable数据
                        }else{
                            $("#tip").html(data['data']);
                        }
                    }
                });

            return false;
        }
    </script>
{% endblock %}